{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from mxnet import nd,autograd,gluon   \n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def transform(x,y):\n",
    "    return x.astype('float32')/255,y.astype('float32')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "mnist_train=gluon.data.vision.FashionMNIST(r'C:\\Users\\ZouJiu\\ch\\FashionMNIST',train=True,transform=transform)\n",
    "mnist_test=gluon.data.vision.FashionMNIST(r'C:\\Users\\ZouJiu\\ch\\FashionMNIST',train=False,transform=transform)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def showImages(xs):\n",
    "    n=xs.shape[0]\n",
    "    _,figs=plt.subplots(1,n,figsize=(10,10))\n",
    "    for i in range(n):\n",
    "        figs[i].imshow(x[i].reshape((28,28)).asnumpy(),cmap='gray')\n",
    "        figs[i].axes.get_xaxis().set_visible(False)\n",
    "        figs[i].axes.get_yaxis().set_visible(False)\n",
    "    plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def getLabels(ys):\n",
    "    labels = ['t-shirt', 'trouser', 'pullover', 'dress,', 'coat',\n",
    "              'sandal', 'shirt', 'sneaker', 'bag', 'ankle boot']\n",
    "    result=[]\n",
    "    for i in ys:\n",
    "        result.append(labels[int(i)])\n",
    "    return result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "batch_size=256\n",
    "train_data=gluon.data.DataLoader(mnist_train,batch_size,shuffle=True)\n",
    "test_data=gluon.data.DataLoader(mnist_test,batch_size,shuffle=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "num_inputs=28*28\n",
    "num_outputs=10\n",
    "w=nd.random_normal(shape=(num_inputs,num_outputs))\n",
    "b=nd.random_normal(shape=num_outputs)\n",
    "params=[w,b]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def softmax(yhat):\n",
    "    exp=nd.exp(yhat)\n",
    "    partition=exp.sum(axis=1,keepdims=True)\n",
    "    return exp/partition"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def net(x):\n",
    "    return softmax(nd.dot(x.reshape((-1,num_inputs)),w)+b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def crossEntropy(yhat,y):\n",
    "    return - nd.log(nd.pick(yhat,y))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "for param in params:\n",
    "    param.attach_grad()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def SGD(params,eta):\n",
    "    for param in params:\n",
    "        param[:]=param-eta*param.grad"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "eta=0.1\n",
    "epochs=10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch 0. Loss:3.623152\n",
      "Epoch 1. Loss:1.930890\n",
      "Epoch 2. Loss:1.596055\n",
      "Epoch 3. Loss:1.419833\n",
      "Epoch 4. Loss:1.307394\n",
      "Epoch 5. Loss:1.224662\n",
      "Epoch 6. Loss:1.165653\n",
      "Epoch 7. Loss:nan\n",
      "Epoch 8. Loss:nan\n",
      "Epoch 9. Loss:nan\n"
     ]
    }
   ],
   "source": [
    "for e in range(epochs):\n",
    "    train_loss=0\n",
    "    for x,y in train_data:\n",
    "        with autograd.record():\n",
    "            yhat=net(x)\n",
    "            loss=crossEntropy(yhat,y)\n",
    "        loss.backward()\n",
    "        SGD(params,eta/batch_size)\n",
    "        train_loss+=nd.mean(loss).asscalar()\n",
    "    print('Epoch %d. Loss:%f'%(e,train_loss/len(train_data)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAkMAAABKCAYAAAC4qVB6AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJztnXmQXUX1x79vtkySYSYThixCYhbAxMqiIKtEEyksgiIu\nILFSqEFZVQotRQQVCAR3LQspSwLuWiUuKFsESSgDEgxbUCExi8SQEBOTSEKSCbO93x9Tn+77zp03\nmeUt+fHO55+XvLn3vtt9u/v2+fY5pzPZbFaO4ziO4ziVSlW5b8BxHMdxHKec+GTIcRzHcZyKxidD\njuM4juNUND4ZchzHcRynovHJkOM4juM4FY1PhhzHcRzHqWh8MuQ4juM4TkXjkyHHcRzHcSoanww5\njuM4jlPR+GTIcRzHcZyKpqY/B2cymdfc3h3ZbDbTl+Nei2WXtCObzR5xsIP6U/a6ujpJUk1NbtOq\nra3N+b66ujrn78ltYewWMZ2dnb1+39raKknq6Ojo621KRSh7XznssMMkSfv27ZMkdXV1adiwYZJi\nvVDWvXv3FvrnpTKW/RCgT2WXXpvlPxTGu8mTJ0uSDhw4oAMHDkiK4wL94IUXXrD3Iyk9BvSHcpa9\nsbFRklRfXy+pu+/T14cMGSIpjme7du0q9M9LRezzDQ0NkuK41tbWJknh2XZ1dUmK5esJnn9VVV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C1Kdt27aF/lQsHnjgAUndm3RTZhSt9evX5xxrlaL+BHRYNdj6Y3IfbBIuSffd\nd1+frz8YnnrqKV1yySWS4qa03BfjNAEtNmhm0qRJea+LryTvC5L1Pv3005LiVl/r1q2TpKI8a1eG\nHMdxHMepaFwZcgYMoewPP/xwCHUkQZgNt0ThwHpEzUENSkZEEDJP6DlWAOfmC0nl/+vXrw9ryuVg\n1qxZkqLFjOqDJc39onA9//zzwf+JsFXIl6LfccrJ2rVrg19HObcdOvPMMyV1K81s1VAs1qxZI0l6\n7LHHwhi0fPnyHo8djM/iwVQk0gqQZuCVV17R0qVLB/x7/SVfWPv8+fOL/ttWgSskrgw5juM4jlPR\nZPoTpZLJZP4rqfDZjsrH67PZ7BF9OfA1WHapj+X3snvZX0NUcp/3sveB12DZJe/zBy+7h+w6juM4\njlPJ+DKZ4ziO4zgVjU+GHMdxHMepaHwy5DiO4zhOReOTIcdxHMdxKhqfDDmO4ziOU9H4ZMhxHMdx\nnIrGJ0OO4ziO41Q0PhlyHMdxHKei8cmQ4ziO4zgVzf8BCJ9/JlwoLIIAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1fe64521a58>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Ground Truth:\n",
      "['t-shirt', 'trouser', 'pullover', 'pullover', 'dress,', 'pullover', 'bag', 'shirt', 'sandal']\n",
      "Prediction:\n",
      "['t-shirt', 't-shirt', 't-shirt', 't-shirt', 't-shirt', 't-shirt', 't-shirt', 't-shirt', 't-shirt']\n"
     ]
    }
   ],
   "source": [
    "xs,ys=mnist_test[0:9]\n",
    "showImages(xs)\n",
    "\n",
    "print('Ground Truth:')\n",
    "print(getLabels(ys))\n",
    "\n",
    "yhat=net(xs).argmax(axis=1)\n",
    "print('Prediction:')\n",
    "print(getLabels(yhat.asnumpy()))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
